using System.Collections.Generic;

namespace OffsetPath
{
    /// <summary>
    /// Classe C mi pare a che fare con profili offsettati effettivamente.
    /// anche input i punti di figura.
    /// </summary>
    public class ClassC : PolygonalShape
    {
        public ClassC()
        {
            base.ExternProfile = new ClassN();
        }

        public ClassC(PolygonalShape A_0)
        {
            base.ExternProfile = new ClassN(A_0.GetExternPolygon());
            for (int i = 0; i < A_0.holesCount(); i++)
            {
                base.PolygonHoles.Add(new ClassN(A_0.GetHolesProfileAt(i)));
            }
        }

        public ClassC(ClassC A_0)
        {
            base.ExternProfile = new ClassN(A_0.a());
            for (int i = 0; i < A_0.holesCount(); i++)
            {
                base.PolygonHoles.Add(new ClassN(A_0.b(i)));
            }
        }

        public ClassC(ClassN A_0)
        {
            base.ExternProfile = new ClassN(A_0);
        }

        public ClassC(OffsetProfilo2D A_0)
        {
            base.ExternProfile = new ClassN(A_0);
        }

        public ClassN a()
        {
            return (base.ExternProfile as ClassN);
        }

        public void a(PolygonalShape A_0)
        {
            base.PolygonHoles.Clear();
            base.ExternProfile = new ClassN(A_0.GetExternPolygon());
            for (int i = 0; i < A_0.holesCount(); i++)
            {
                base.PolygonHoles.Add(new ClassN(A_0.GetHolesProfileAt(i)));
            }
        }

        public void a(ClassC A_0)
        {
            base.PolygonHoles.Clear();
            base.ExternProfile = new ClassN(A_0.a());
            for (int i = 0; i < A_0.holesCount(); i++)
            {
                base.PolygonHoles.Add(new ClassN(A_0.b(i)));
            }
        }

        public void a(ClassN A_0)
        {
            base.ExternProfile = A_0;
        }

        public void a(OffsetProfilo2D A_0)
        {
            if (A_0 is ClassN)
            {
                base.PolygonHoles.Add(A_0);
            }
        }

        public void a(double A_0)
        {
            base.MethodA1(A_0, this.c());
        }

        public void a(int A_0)
        {
            base.PolygonHoles.RemoveAt(A_0);
        }

        public void a(int A_0, ClassN A_1)
        {
            base.PolygonHoles[A_0] = A_1;
        }

        public void a(int A_0, OffsetProfilo2D A_1)
        {
            if (A_1 is ClassN)
            {
                base.PolygonHoles[A_0] = A_1;
            }
        }

        public void a(ClassC A_0, List<ClassC> A_1, ClassAg A_2)
        {
            List<PolygonalShape> list = new List<PolygonalShape>();
            base.MethodA1(A_0, list, A_2);
            for (int i = 0; i < list.Count; i++)
            {
                A_1.Add(new ClassC(list[i]));
            }
        }

        public double b()
        {
            double num = 0.0;
            num += this.a().n();
            for (int i = 0; i < base.PolygonHoles.Count; i++)
            {
                num -= this.b(i).n();
            }
            return num;
        }

        public void b(ClassN A_0)
        {
            base.PolygonHoles.Add(A_0);
        }

        public void b(double A_0)
        {
            this.a().MethodB(A_0);
            for (int i = 0; i < base.PolygonHoles.Count; i++)
            {
                this.b(i).MethodB(-A_0);
            }
        }

        public ClassN b(int A_0)
        {
            return (base.PolygonHoles[A_0] as ClassN);
        }

        public void b(ClassC A_0, List<ClassC> A_1, ClassAg A_2)
        {
            List<PolygonalShape> list = new List<PolygonalShape>();
            base.MethodB1(A_0, list, A_2);
            for (int i = 0; i < list.Count; i++)
            {
                A_1.Add(new ClassC(list[i]));
            }
        }

        public PuntoDueD c()
        {
            PuntoDueD puntoDueD = new PuntoDueD(0.0, 0.0);
            if (base.PolygonHoles.Count == 0)
            {
                return this.a().q();
            }
            PuntoDueD x2 = this.a().q();
            double num = this.a().n();
            double num2 = 0.0;
            for (int i = 0; i < base.PolygonHoles.Count; i++)
            {
                num2 += this.b(i).n();
            }
            if ((num2 == 0.0) || (num2 == num))
            {
                return this.a().q();
            }
            for (int j = 0; j < base.PolygonHoles.Count; j++)
            {
                PuntoDueD x3 = this.b(j).q();
                x3.MethodA((double) (this.b(j).n() / num2));
                puntoDueD = PuntoDueD.MethodB(puntoDueD, x3);
            }
            ClassAtPuntoIncrementale classAt = new ClassAtPuntoIncrementale(puntoDueD, x2);
            classAt.d((double) (num2 / (num - num2)));
            x2.p(classAt);
            return x2;
        }

        public void c(double A_0)
        {
            base.MethodB1(A_0, this.c());
        }

        public void c(ClassC A_0, List<ClassC> A_1, ClassAg A_2)
        {
            List<PolygonalShape> list = new List<PolygonalShape>();
            base.c(A_0, list, A_2);
            for (int i = 0; i < list.Count; i++)
            {
                A_1.Add(new ClassC(list[i]));
            }
        }

        public bool d(double A_0)
        {
            if ((this.a() != null) && this.a().d(A_0))
            {
                return true;
            }
            int num = 0;
            while (num < base.PolygonHoles.Count)
            {
                if (this.b(num).d(A_0))
                {
                    base.PolygonHoles.RemoveAt(num);
                }
                else
                {
                    num++;
                }
            }
            return false;
        }

        ~ClassC()
        {
        }
    }
}

